﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ex6.FilterNumbers
{
    class FilterNumbers
    {
        static int[] NumberFilter(int[] array)
        {
            List<int> listOfNumbers = new List<int>(array);
            List<int> result = listOfNumbers.FindAll(number => number % 7 == 0 && number % 3 == 0);
            return result.ToArray();
        }

        static int[] NumberFilterWithLINQ(int[] array)
        {
            var filteredNumbers =
                from number in array
                where number % 3 == 0 && number % 7 == 0
                select number;
            return filteredNumbers.ToArray();
        }

        static void Main(string[] args)
        {
            int[] myArray = new int[] { 3, 5, 6, 7, 21 };

            var filteredNumbers = NumberFilter(myArray);
            Console.WriteLine("Extension Filter: ");
            foreach (var number in filteredNumbers)
            {
                Console.Write("{0} ",number);
            }
            Console.WriteLine();


            filteredNumbers = NumberFilterWithLINQ(myArray);
            Console.WriteLine("Extension Filter: ");
            foreach (var number in filteredNumbers)
            {
                Console.Write("{0} ", number);
            }
            Console.WriteLine();

        }
    }
}
